package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.LocationXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：2016/10/20 10:12
 * 修改备注：
 * ================================================
 */

public class BusinessExpert {

    /**
     * 获取专家列表接口
     *
     * @param activity
     * @param minTypeCode 查询类型code
     * @param handler
     */
    public static void getExpertList(Activity activity, String offset, String limit, String minTypeCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("minTypeCode", minTypeCode);

        OkHttpUtil.post(activity, URL.URL_GET_EXPERT_LIST, "", params, handler,
                MSG.MSG_GET_EXPERT_LIST_SUCCESS, MSG.MSG_GET_EXPERT_LIST_FIELD);

    }

    /**
     * 签约专家列表  2017年10月12日 16:05:34 新增
     *
     * @param activity
     * @param offset
     * @param limit
     * @param minTypeCode 小类code
     * @param expertLevel 专家级别
     * @param handler
     */
    public static void getChatExperts(Activity activity, String offset, String limit, String minTypeCode, String expertLevel, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("minTypeCode", minTypeCode);
        params.put("expertLevel", expertLevel);

        OkHttpUtil.post(activity, URL.URL_GET_CHAT_EXPERTS, "", params, handler,
                MSG.MSG_GET_CHAT_EXPERTS_SUCCESS, MSG.MSG_GET_CHAT_EXPERTS_FIELD);

    }

    /**
     * 新获取专家列表接口
     *
     * @param activity
     * @param handler
     */
    public static void getNewExpertList(Activity activity, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("useraccid", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_NEW_GET_EXPERT_LIST, "", params, handler,
                MSG.MSG_NEW_GET_EXPERT_LIST_SUCCESS, MSG.MSG_NEW_GET_EXPERT_LIST_FIELD);

    }

    /**
     * 根据code搜索专家列表
     *
     * @param activity
     * @param offset
     * @param limit
     * @param maxTypeCode 父code
     * @param minTypeCode 子code
     * @param handler
     */
    public static void expertSelect(Activity activity, String offset, String limit, String maxTypeCode, String minTypeCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("offset", offset);
        params.put("limit", limit);
//        params.put("maxTypeCode", maxTypeCode);
        params.put("minTypeCode", minTypeCode);

        OkHttpUtil.post(activity, URL.URL_EXPERT_SELECT, "", params, handler,
                MSG.MSG_EXPERT_SELECT_SUCCESS, MSG.MSG_EXPERT_SELECT_FIELD);

    }

    /**
     * 获取专家详情接口
     *
     * @param activity
     * @param id       专家主键
     * @param handler
     */
    public static void getExpertDetails(Activity activity, String id, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);

        OkHttpUtil.post(activity, URL.URL_GET_EXPERT_DETAILS, "", params, handler,
                MSG.MSG_GET_EXPERT_DETAILS_SUCCESS, MSG.MSG_GET_EXPERT_DETAILS_FIELD);

    }

    /**
     * 获取专家详情接口
     *
     * @param activity
     * @param id       专家主键
     * @param handler
     */
    public static void getExpertDetailList(Activity activity, String id, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);

        OkHttpUtil.post(activity, URL.URL_GET_EXPERT_DETAILS_LIST, "", params, handler,
                MSG.MSG_GET_EXPERT_DETAILS_SUCCESS, MSG.MSG_GET_EXPERT_DETAILS_FIELD);

    }


    /**
     * 专家分类列表
     *
     * @param activity
     * @param handler
     */
    public static void getExpertTypeList(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_GET_EXPERT_TYPE_LIST, "", params, handler,
                MSG.MSG_GET_EXPERT_TYPE_LIST_SUCCESS, MSG.MSG_GET_EXPERT_TYPE_LIST_FIELD);

    }

    /**
     * 新版农业专家分类  只展示已签约的专家分类
     *
     * @param activity
     * @param consultIsFee 0是免费专家（一键提问需要）1是收费
     * @param handler
     */
    public static void expertTypeChat(Activity activity, String consultIsFee, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("consultIsFee", consultIsFee);

        OkHttpUtil.post(activity, URL.URL_EXPERT_TYPE_CHAT, "", params, handler,
                MSG.MSG_EXPERT_TYPE_CHAT_SUCCESS, MSG.MSG_EXPERT_TYPE_CHAT_FIELD);

    }

    /**
     * 群发历史列表
     *
     * @param activity
     * @param handler
     */
    public static void getGroupMessage(Activity activity, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("offset", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_GROUP_MESSAGE, "", params, handler,
                MSG.MSG_GET_GROUP_MESSAGE_SUCCESS, MSG.MSG_GET_GROUP_MESSAGE_FIELD);

    }


    /**
     * 保存群发消息接口
     *
     * @param activity
     * @param typeCode 专家分类code
     * @param areaCode 专家领域code
     * @param content  群发消息内容
     * @param imgs     群发图片，以逗号隔开
     * @param handler
     */
    public static void saveGroupMsg(Activity activity, String typeCode, String areaCode, String content, String imgs, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("typeCode", typeCode);
        params.put("areaCode", areaCode);
        params.put("content", content);
        params.put("imgs", imgs);

        OkHttpUtil.post(activity, URL.URL_SAVE_GROUP_MSG, "正在发送", params, handler,
                MSG.MSG_SAVE_GROUP_MSG_SUCCESS, MSG.MSG_SAVE_GROUP_MSG_FIELD);

    }

    /**
     * 专家信息表单提交
     *
     * @param activity
     * @param value    提交数据集合 必须按照顺序传递
     * @param handler
     */
    public static void saveExpertInfo(Activity activity, String value[], Handler handler) {

        HttpParams params = new HttpParams();
        params.put("photo", value[0]);      // 头像
        params.put("expertId", value[1]);   // 专家useraccid
        params.put("expertName", value[2]); // 真实姓名
        params.put("expertSex", value[3]);      // 专家性别
        params.put("expertTitleId", value[4]);      // 专家职称id
        params.put("workUnit", value[5]);      // 工作单位
        params.put("provinceCode", value[6]);      // 省份code
        params.put("cityCode", value[7]);      // 市 code
        params.put("countyCode", value[8]);      // 区县 code
        params.put("addressDetail", value[9]);      // 详细地址
        params.put("expertTitleNum", value[10]);      // 专家职称号
        params.put("expertTitleImage", value[11]);      // 专家职称照片
        params.put("idCardNum", value[12]);      // 身份证号
        params.put("idCardImage", value[13]);      // 身份证照片
        params.put("expertIntroduce", value[14]);      // 个人简介
        params.put("achievement", value[15]);      // 个人成就
        params.put("expertAreaTypeCode", value[16]);      // 专家领域（三类）
        params.put("expertAreaDirectionCode", value[17]);      // 专家领域（方向）
        params.put("organizationId", value[18]); // 工作单位Id
        params.put("otherAddress", value[19]); // 其他地址

        OkHttpUtil.post(activity, URL.URL_SAVE_EXPERT_INFO, "提交中 请稍候...", params, handler,
                MSG.MSG_SAVE_EXPERT_INFO_SUCCESS, MSG.MSG_SAVE_EXPERT_INFO_FIELD);

    }

    /**
     * 专家信息表单提交 - 不包含认证信息
     *
     * @param activity
     * @param params
     * @param handler
     */
    public static void saveExpertInfoBase(Activity activity, HttpParams params, Handler handler) {

        params.put("type", "1");
        params.put("expertId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_SAVE_EXPERT_INFO, "提交中 请稍候...", params, handler,
                MSG.MSG_SAVE_EXPERT_INFO_SUCCESS, MSG.MSG_SAVE_EXPERT_INFO_FIELD);

    }

    /**
     * 专家职称列表
     *
     * @param activity
     * @param handler
     */
    public static void expertTitleList(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("page", "1");
        params.put("limit", "100");

        OkHttpUtil.post(activity, URL.URL_EXPERT_TITLE_LIST, "", params, handler,
                MSG.MSG_EXPERT_TITLE_LIST_SUCCESS, MSG.MSG_EXPERT_TITLE_LIST_FIELD);

    }

    /**
     * 专家分类及领域
     *
     * @param activity
     * @param handler
     */
    public static void primaryClassificationAll(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_PRIMARY_CLASSIFICATION_ALL, "", params, handler,
                MSG.MSG_PRIMARY_CLASSIFICATION_ALL_SUCCESS, MSG.MSG_PRIMARY_CLASSIFICATION_ALL_FIELD);

    }

    /**
     * 我的专家列表分类及领域
     *
     * @param activity
     * @param handler
     */
    public static void myExpertSearchType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("cityName", LocationXML.getCity(activity));

        OkHttpUtil.post(activity, URL.URL_MY_EXPERT_SEARCH_TYPE_BY_ORG, "", params, handler,
                MSG.MSG_MYEXPERTS_SEARCHTYPE_SUCCESS, MSG.MSG_MYEXPERTS_SEARCHTYPE_FIELD);

    }

    /**
     * 咨询专家列表分类及领域
     *
     * @param activity
     * @param handler
     */
    public static void expertSearchType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_MYEXPERTS_CLASSIFICATION_ALL, "", params, handler,
                MSG.MSG_MYEXPERTS_SEARCHTYPE_SUCCESS, MSG.MSG_MYEXPERTS_SEARCHTYPE_FIELD);

    }

    /**
     * 咨询专家分类<只包含有专家的分类>
     *
     * @param activity
     * @param handler
     */
    public static void questionType(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_QUESTION_TYPE, "", params, handler,
                MSG.MSG_QUESTION_TYPE_SUCCESS, MSG.MSG_QUESTION_TYPE_FIELD);

    }


    /**
     * 农家专访列表
     *
     * @param activity
     * @param type      0 本期   1 往期
     * @param orderType 排序类型  1 时间  2 阅读量
     * @param page
     * @param limit
     * @param handler
     */
    public static void getInterViewList(Activity activity, String type, String orderType, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("type", type);
        params.put("orderType", orderType);
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_INTER_VIEW_LIST, "", params, handler,
                MSG.MSG_GET_INTER_VIEW_LIST_SUCCESS, MSG.MSG_GET_INTER_VIEW_LIST_FIELD);

    }


    /**
     * 我的专家--专家团队列表
     *
     * @param activity
     * @param provinceName 省名称
     * @param cityName     市名称
     * @param page
     * @param limit
     * @param handler
     */
    public static void orgAppList(Activity activity, String provinceName, String cityName, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("provinceName", provinceName);
        params.put("cityName", cityName);
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_MY_EXPERTS_LIST, "", params, handler,
                MSG.MSG_MYEXPERTS_LIST_SUCCESS, MSG.MSG_MYEXPERTS_LIST_FIELD);

    }

    /**
     * 我的专家列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void myExpertList(Activity activity, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_OPERATE_EXPERTS_LIST, "", params, handler,
                MSG.MSG_OPERATE_EXPERTS_SUCCESS, MSG.MSG_OPERATE_EXPERTS_FIELD);

    }


    /**
     *  *专家搜索列表
     *  *
     *  * @param keywords     关键字
     *  * @param userAccId    登陆人ID
     *  * @param eClassCode   专家三级分类
     *  * @param rDirectCode  专家领域分类
     *  * @param orgID        组织机构ID
     *  * @param sortType     排序类型 ： 空 or 0--默认排序  1--推荐专家  2--职称级别  3--距离排序
     *  * @param provinceName 省编码
     *  * @param cityName     市编码
     *  * @param page         页码
     *  * @param limit        条数
     *  
     */
    public static void expertSearchList(Activity activity, String keywords, String eClassCode,
                                        String rDirectCode, String orgID, String sortType, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("keywords", keywords);
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("eClassCode", eClassCode);
        params.put("rDirectCode", rDirectCode);
        params.put("orgID", orgID);
        params.put("sortType", sortType);
        params.put("provinceName", "");
        params.put("cityName", LocationXML.getCity(activity));
        params.put("countyName", LocationXML.getDistrict(activity));
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_SEARCH_ADD_EXPERTS_LIST, "", params, handler,
                MSG.MSG_SEARCH_ADD_EXPERTS_SUCCESS, MSG.MSG_SEARCH_ADD_EXPERTS_FIELD);

    }


    /**
     *  * 添加我的专家列表
     *  *
     *  * @param keywords     关键字
     *  * @param userAccId    登陆人ID
     *  * @param eClassCode   专家三级分类
     *  * @param rDirectCode  专家领域分类
     *  * @param orgID        组织机构ID
     *  * @param sortType     排序类型 ： 空 or 0--默认排序  1--推荐专家  2--职称级别
     *  * @param provinceName 省编码
     *  * @param cityName     市编码
     *  * @param page         页码
     *  * @param limit        条数
     *  
     */
    public static void expertDefaultList(Activity activity, String keywords, String eClassCode,
                                         String rDirectCode, String orgID, String sortType, String page, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("keywords", keywords);
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("eClassCode", eClassCode);
        params.put("rDirectCode", rDirectCode);
        params.put("orgID", orgID);
        params.put("sortType", sortType);
        params.put("provinceName", "");
        params.put("cityName", LocationXML.getCity(activity));
        params.put("page", page);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_DEFAULT_ADD_EXPERTS_LIST, "", params, handler,
                MSG.MSG_SEARCH_ADD_EXPERTS_SUCCESS, MSG.MSG_SEARCH_ADD_EXPERTS_FIELD);

    }


    /**
     *  * 添加专家
     *  *
     *  * @param expertIds     专家id
     *  
     */
    public static void saveMyExpert(Activity activity, String expertIds, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("expertIds", expertIds);

        OkHttpUtil.post(activity, URL.URL_ADD_EXPERTS, "", params, handler,
                MSG.MSG_ADD_EXPERTS_SUCCESS, MSG.MSG_ADD_EXPERTS_FIELD);

    }

    /**
     *  * 删除专家
     *  *
     *  * @param expertIds     专家id
     *  
     */
    public static void deleteMyExpert(Activity activity, String expertIds, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("myExpertId", expertIds);

        OkHttpUtil.post(activity, URL.URL_DELETE_EXPERTS, "", params, handler,
                MSG.MSG_DELETE_EXPERTS_SUCCESS, MSG.MSG_DELETE_EXPERTS_FIELD);

    }
}
